<?php
/**
 * ===============================================
 * 版权所有 2019-2050 青岛铁锤科技有限公司，并保留所有权利。
 * 网站地址: http://www.huaxianling.com
 * ===============================================
 * Author: Happy dong
 * Created Time: 2019-07-19 09:24
 *
 * Version: 2.0
 */

namespace App\Models;


use Illuminate\Database\Eloquent\Model;

class MemberCoin extends Model
{
	protected $table = "member_coin";
	protected $fillable = [
		'member_id',
		'store_id',
		'coin',
		'coin_date',
		'source',
		'link_id'
	];


	public function coinType(){
		if($this->type == 1){
			return $this->hasOne(Order::class,'id','link_id');
		}elseif($this->type=2){
			return $this->hasOne(OrderItem::class,'id','link_id');
		}
	}


	public function order(){
		return $this->hasOne(Order::class,'id','link_id');
	}
}